home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
TDMouse-1.1os.lha
/
TDMouse
/
ev.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-10-06
|
2KB
|
110 lines
struct IOStdReq *io;
APTR port;
LONG dev=-1;
struct Interrupt it;
struct InputEvent *e0,*e1;
LONG Sig;
ULONG SignalMask;
APTR MainTask;
extern APTR UserRoutine;
int i,j,k;
main()
{
ULONG co;
UBYTE *a,*b,*c,*d;
port=CreatePort(0,0);
io=CreateExtIO(port,1024);
dev=OpenDevice("input.device",0,io,0);
e0=AllocMem(200,MEMF_CLEAR|MEMF_PUBLIC);
e1=AllocMem(200,MEMF_CLEAR|MEMF_PUBLIC);
if(dev!=0) { puts("Error!"); exit(0); }
Sig=AllocSignal(-1L);
SignalMask=(1L<<Sig);
MainTask=FindTask(NULL);
it.is_Data=NULL;
it.is_Code=&UserRoutine;
it.is_Node.ln_Succ=NULL;
it.is_Node.ln_Pred=NULL;
it.is_Node.ln_Type=NT_INTERRUPT;
it.is_Node.ln_Name="test.interrupt";
it.is_Node.ln_Pri=51;
io->io_Data=
io->io_Length=sizeof(struct Interrupt);
io->io_Command=IND_ADDHANDLER;
puts("init...");
DoIO(io);
puts("ok!");
for(;;)
{
Wait(SignalMask);
Disable();
CopyMem(e0,e1,sizeof(struct InputEvent));
Enable();
co=0;
co=e1->ie_Qualifier;
a=b=c=d=" ";
if(co & IEQUALIFIER_LEFTBUTTON) a="L";
if(co & IEQUALIFIER_RBUTTON) b="R";
if(e1->ie_Class==IECLASS_RAWKEY) c="Rawkey";
else if(e1->ie_Class==IECLASS_RAWMOUSE) c="RMouse";
/*
printf("%s %s %s\n",c,a,b);
*/
printf("%2lx %2lx C=%4lx Q=%4lx %4ld %4ld %lx\n",
e0->ie_Class,
e0->ie_SubClass,
e0->ie_Code,
e0->ie_Qualifier,
e0->ie_X,e0->ie_Y,e0->ie_NextEvent);
/*
printf("%02lx X=%ld Y=%ld %ld %s %s %s %s\n",e1->ie_Class,e1->ie_X,e1->ie_Y,co,a,b,c,d);
*/
}
/*
CloseDevice(io);
DeleteExtIO(io);
DeletePort(port);
exit(0);
*/
}
#asm
public _geta4
public _UserRoutine
_UserRoutine:
movem.l a0-a6/d0-d7,-(sp)
jsr _geta4
move.l a0,-(sp)
jsr _CRoutine
addq.w #4,sp
movem.l (sp)+,a0-a6/d0-d7
rts
#endasm
void CRoutine(ev)
struct InputEvent *ev;
{
if(ev->ie_Class!=IECLASS_RAWMOUSE)
if(ev->ie_Class!=IECLASS_POINTERPOS)
if(ev->ie_Class!=IECLASS_RAWKEY)
return;
CopyMem(ev,e0,sizeof(struct InputEvent));
/*
ev->ie_X=(WORD)(-(WORD)ev->ie_X);
ev->ie_Y=(WORD)(-(WORD)ev->ie_Y);
*/
Signal(MainTask,SignalMask);
}